PROCEDURE (s: Setter) GridOffset (dsc: LONGINT; VAR box: LineBox): LONGINT
END;
LineBox = RECORD
len: LONGINT;
ruler: TextRulers.Ruler;
rpos: LONGINT;
left, right, asc, dsc: LONGINT;
rbox, bop, adj, eot, views: BOOLEAN;
skipOff: LONGINT;
adjOff: LONGINT;
spaces: INTEGER;
adjW: LONGINT
END;
Directory = POINTER TO DirectoryDesc;
DirectoryDesc = RECORD
PROCEDURE (d: Directory) New (): Setter
END;
VAR dir-, stdDir-: Directory;
PROCEDURE SetDir (d: Directory);
END TextSetters.
TextSetters set texts (one-dimensional streams of characters and embedded views) into two
dimensional columns or pages. Special text
aware views embedded in the set text, so-called rulers, are interpreted as requests for special setting formats.
Warning: The interface of TextSetters and its role in the text subsystem may change in future releases of Oberon/F. (TextSetters is included in this documentation for its fundamental role in the task performed by TextViews.)
CONST lineBreak, wordJoin, wordPart, flexWidth
Possible values of Pref.opts indicating preferences of setter
aware views embedded in a text. The inclusion of lineBreak overrides any possible inclusion of wordJoin.
If lineBreak is included, the setter is requested to break the line just after the view.
If wordJoin is included, the view requests that it should not be used as a position to break the words to the left and to the right of the view at the end of a line.
If wordPart is included, the view is treated as part of the word that it is embedded into (which effects the range selected by a "select word" operation).
If flexWidth is included, the view is treated the same way as ordinary blanks, i.e. its width is adjusted when setting a line in fully adjusted mode.
CONST char, lchar, view, string, lstring
Possible elements of Reader.type, indicating which of the reader fields are valid. {char, lchar, view} correspond to the constants of same name defined in TextModels.
TYPE LONGCHAR
Type of long characters.
TYPE Pref
Possible preferences of setter
aware views embedded into a text.
opts: SET
Setting options drawn from {lineBreak, wordJoin, wordPart, flexWidth}, as defined above.
endW: LONGINT preset to width of view
If view happens to be placed at the end of a line, i.e. a line break is immediately following, the view may request a width different from its usual width. (For example, a soft
hyphen has a positive end width, while it has a zero width; a blank has a positive width, but a zero end width.)
dsc: LONGINT preset to dominating line descender
A view may request a special descender value, thereby adjusting its placement relative to the baseline.
TYPE Reader
Interface
A reader to read through lines returned by a setter. The reader is a conceptual extension of a TextModels.Reader, but instead of just returning the elements of a stream, it also sets the elements on a line and returns placement coordinates relative to the lines baseline origin.
r-: TextModels.Reader
The text reader used to connect the reader to a text. The text reader state is used as a one element look
ahead state for the reader.
type-: SET
The type of possible interpretations of the element last read, drawn from {char, lchar, view, string, lstring}. The validity of the fields string, lstring, and view depends on this field.
string: ARRAY 64 OF CHAR
The element read most recently was a character (char IN type) or string of characters (string IN type). Single characters are returned in string[0]. In case of char IN type and view IN type, the element read most recently was a view masked as a character.
lstring: ARRAY 64 OF LONGCHAR
The element read most recently was a long character (lchar IN type) or string of long characters (lstring IN type). Single long characters are returned in lstring[0]. In case of lchar IN type and view IN type, the element read most recently was a view masked as a long character.
view: Views.View;
The element read most recentlyd was an embedded view.
textOpts: SET
mask: LONGCHAR
setterOpts: SET
w, endW, h, dsc: LONGINT
attr: TextModels.Attributes
Properties of the element read most recently: Its text options (if text
aware, else preset default); its mask character (if TextModels.maskChar IN textOpts); its setter options (if setter
aware, else preset default); its width, end width (if setter
aware, else preset default), height, and descender (if setter
aware, else preset default); its text attributes.
eot: BOOLEAN
Set if the last trial to read hit the end of text.
pos: LONGINT
Position of the reader in the text (one past the element read most recently).
x: LONGINT
Horizontal position of the reader in the line. To be advanced by client of reader. For non
adjusted setting, increment by w, else utilize AdjustWidth below.
adjStart: LONGINT
The first position (inclusive) to begin space adjustment at. This is used to suppress space adjustment in all but the last section of several tab-separated sections of a line.
spaces: INTEGER
Number of spaces encountered by reader so far. (Reset to 0 when adjStart gets reset on reading a tab.)
hideMarks: BOOLEAN
Hideable marks are requested to be hidden in the currect line. If the reader encounters an embedded view that by its text preferences is hideable and hideMarks is set, then the view is reduced to zero width and height.
ruler: TextRulers.Ruler
Ruler dominating the setting of the current line.
rpos: LONGINT
Position of the dominating ruler in the text. (rpos = -1 if the ruler is not part of the text and there is no ruler in the text that dominates the current line. Typically, this is used to apply a default ruler to the beginning of a text that has no ruler at position 0.)
PROCEDURE (rd: Reader) Set (old: TextModels.Reader;
using an old text reader that is no longer in use. The reader is given the text, the line's horizontal left margin x, the line's starting position pos , the ruler and its position rpos dominating the line, and whether hideable marks are to be hidden.
Given a line box, its starting position start, and a position pos, AdjustWidth takes an element's width w and adjusts it according to the formatting requirements of the line.
For the element read last by the reader, compute a split width. This is used for interactive purposes, where the split width splits coordinates into two half intervals: All coordinates left of the split point belong to the left edge of the element, all coordinates right of the split point belong to the right edge.
0 <= result <= w
TYPE Setter
Interface, Extension
A setter can be used to set a text into lines, paragraphs, columns, and pages.
text-: TextModels.Model setter connected iff text # NIL
Text to be set.
defRuler-: TextRulers.Ruler
Default ruler to be used to set the beginning of the text, in case the text has no ruler at position 0.
hideMarks-: BOOLEAN
If set, all embedded views that are by their preference hideable, will be reduced to zero width and zero height.
PROCEDURE (s: Setter) Clone (): Setter
Default, Extension
Result type is narrowed.
PROCEDURE (s: Setter) CopyFrom (source: Setter)
Copy a non
initialized setter from an initialized source setter.
Disconnect setter from the text it was previously connected to (if any), and connect setter to given text (if any) using default ruler defRuler and hiding marks if requested by hideMarks.
Locate the starting position of the previous line, given the starting position start of the current line.
Connected(s) 20
0 <= start 21
start <= s.text.Length() 22
s.ThisLine(start) = start 23
start = 0
result = 0
start > 0
result < start
result = s.ThisLine(start - 1)
PROCEDURE (s: Setter) GetWord (pos: LONGINT; VAR beg, end: LONGINT)
Locate the beginning and ending positions of the word containing position pos. A word is a sequence of characters with code > " ", or views with mask > " ", or views with preference wordPart.
Connected(s) 20
0 <= pos 21
pos <= s.text.Length() 22
beg <= pos <= end
PROCEDURE (s: Setter) GetLine (start: LONGINT; VAR box: LineBox)
Interface
Compute the characteristic box of the line with starting position start. (Cf. type LineBox below.)
Get the bounding box of a text stretch beginning at a line starting position start and ending at position end. The box computation will terminate if either the text stretch has been fully set, or if the box reached either of the limits, maxW bounding the box width, or maxH bounding the box height.
Return a new reader, possibly reusing a given old reader that is no longer in use. (Whether the old reader is actually reused depends on internal compatibility conditions.)
Connected(s) 20
result # NIL
PROCEDURE (s: Setter) GridOffset (dsc: LONGINT; VAR box: LineBox): LONGINT
Given the descender dsc of the preceding line and the current line characteristics box, return the grid correction to force the current line to the line grid. If the current line is the first line (of the text or on the current page), dsc = -1 should be passed.
Ruler dominating the line, and its position in the text. (rpos = -1 indicates that the line is dominated by the default ruler.)
left, right, asc, dsc: LONGINT
Left and right margins, and ascender and descender of the line's bounding box.
rbox: BOOLEAN
The line solely contains a ruler or a paragraph separator (para character or mask).
bop: BOOLEAN
The line is the first of a paragraph: Its left margin is ruler.first.; otherwise the left margin is ruler.left.
adj: BOOLEAN
The line needs adjustment when finally rendered: At least one element of the line needs to be artificially changed in width to achieve the requested formatting effect.
eot: BOOLEAN
The line is either empty, or it contains the last element of the text which is neither a line nor a para character or mask.
views: BOOLEAN
The line contains at least one embedded view.
skipOff: LONGINT 0 <= skipOff <= len
The characters in [skipOff, len) take on width endW.
adjOff: LONGINT 0 <= adjOff <= len
Offset of last block (sequence with no tab enclosed) in box. If the line is adjusted (centered, right flush, or fully adjusted), then this is the offset into the line where adjustment begins.
spaces: INTEGER valid and > 0 if adj
Number of spaces subject to adjustment.
adjW: LONGINT valid and > 0 if adj
The adjustment delta to be added either to the front of the last block for centered or right flushed formats, or to each space element (blank or view mapped to blank or view with preference flexWidth) for fully adjusted formats.
TYPE Directory
Interface
Directory for setters.
PROCEDURE (d: Directory) New (): Setter
Interface
Return a new setter.
VAR dir-, stdDir-: Directory dir # NIL, stdDir # NIL, stable stdDir = d